package com.tiancheng.onecode.utils;

import com.tiancheng.onecode.model.dto.PayMerchantDTO;
import com.tiancheng.onecode.model.dto.PayPlatformDTO;

/**
 * @author jiangjun
 * @description 商户信息上下文
 * @date 2024/12/11 14:02
 */
public class MerchantContext {

    private static final ThreadLocal<PayMerchantDTO> merchantThreadLocal = new ThreadLocal<>();
    private static final ThreadLocal<PayPlatformDTO> platformThreadLocal = new ThreadLocal<>();

    public static void setMerchant(PayMerchantDTO merchantInfo) {
        merchantThreadLocal.set(merchantInfo);
    }
    public static void setPlatform(PayPlatformDTO payPlatformDTO) {
        platformThreadLocal.set(payPlatformDTO);
    }

    public static PayMerchantDTO getMerchant() {
        return merchantThreadLocal.get();
    }

    public static PayPlatformDTO getPlatform() {
        return platformThreadLocal.get();
    }

    public static void clear() {
        merchantThreadLocal.remove();
        platformThreadLocal.remove();
    }
}
